#include<stdio.h>
#include<unistd.h>

int testpram1 = 100;

int main()
{
    pid_t id = fork();
    int cnt = 3;
    if(id == 0)
    {
        while(1)
        {
            printf("我是子进程,PID是:%d,PPID是:%d\n",getpid(),getppid());
            if(cnt) cnt--;
            
            if(cnt == 0)
            {
                testpram1 = 200;
                printf("testpram1 = %d, &testpram1 = %p\n", testpram1, &testpram1);
                sleep(1);
            }
            else
            {
                printf("testpram1 = %d, &testpram1 = %p\n", testpram1, &testpram1);
                sleep(1);
            }
        }
    }
    else 
    {
        while(1)
        {
            printf("我是父进程,PID是:%d,PPID是:%d\n",getpid(),getppid());
            printf("testpram1 = %d, &testpram1 = %p\n", testpram1, &testpram1);
            sleep(1);
        }
    }
    return 0;
}
